import 'package:flutter/material.dart';
import 'package:x3_charts_core/chart_painter/annular_disc_chart_painter.dart';
import 'package:x3_charts_core/model/annular_disc_chart_model.dart';

///**
///* Description:  多环形圆盘
///*/

class AnnularDiscChartWidget extends StatefulWidget {
  final List<AnnularDiscChartModel> chartList;

  AnnularDiscChartWidget({@required this.chartList});

  @override
  _AnnularDiscChartWidgetState createState() => _AnnularDiscChartWidgetState();
}

class _AnnularDiscChartWidgetState extends State<AnnularDiscChartWidget> with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: const Duration(milliseconds: 1000),
      vsync: this,
    )..forward();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: LayoutBuilder(
        builder: (BuildContext context, BoxConstraints constraints) {
          return CustomPaint(
            size: Size(constraints.maxWidth, constraints.maxHeight),
            painter: AnnularDiscChartPainter(chartList: widget.chartList, repaint: _controller),
          );
        },
      ),
    );
  }
}
